//
//  AlbumTableViewCell.m
//  HimalayaMusic
//
//  Created by dllo on 16/1/9.
//  Copyright © 2016年 WXCLegendary. All rights reserved.
//

#import "AlbumTableViewCell.h"

@implementation AlbumTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.mainImage = [[UIImageView alloc] init];
        self.mainImage.layer.masksToBounds = YES;
        
        [self addSubview:self.mainImage];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.titleLabel];
        
        //底部一些标签初始化
        self.playImage = [[UIImageView alloc] init];
        self.playImage.image = [UIImage imageNamed:@"play"];
        [self addSubview:self.playImage];
        
        self.playTimesLabel = [[UILabel alloc] init];
        self.playTimesLabel.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.playTimesLabel];
        
        self.durationTimeImage = [[UIImageView alloc] init];
        self.durationTimeImage.image = [UIImage imageNamed:@"clock"];
        [self addSubview:self.durationTimeImage];
        
        self.durationTimeLabel = [[UILabel alloc] init];
        self.durationTimeLabel.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.durationTimeLabel];
        
        self.timeLabel = [[UILabel alloc] init];
        self.timeLabel.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.timeLabel];
        
        
        
        
    }
    return self;
    
    
}


- (void)layoutSubviews {
    [super layoutSubviews];
    self.mainImage.frame = CGRectMake(5, 5, self.height - 10, self.height - 10);
    self.mainImage.layer.cornerRadius = (self.height - 10) / 2;
    
    self.titleLabel.frame = CGRectMake(self.mainImage.right + 5, self.mainImage.top, self.width - self.mainImage.right - 10, self.mainImage.height / 2);
    self.playImage.frame = CGRectMake(self.titleLabel.left, self.titleLabel.bottom + 10, 20, 20);
    
    self.playTimesLabel.frame = CGRectMake(self.playImage.right + 5, self.playImage.top, 50, self.playImage.height);
    
    self.durationTimeImage.frame  =CGRectMake(self.playTimesLabel.right, self.playImage.top, self.playImage.width, self.playImage.height);
    

    self.durationTimeLabel.frame = CGRectMake(self.durationTimeImage.right, self.playImage.top, 40, self.playImage.height);
    
    self.timeLabel.frame = CGRectMake(self.durationTimeLabel.right, self.playImage.top, 70, self.playTimesLabel.height);

    
}


-(void)setAlbumListModel:(AlbumListModel *)albumListModel {
    if (_albumListModel != albumListModel) {
        _albumListModel = albumListModel;
    }
    
    [self.mainImage sd_setImageWithURL:[NSURL URLWithString:self.albumListModel.coverMiddle]];
    self.titleLabel.text = self.albumListModel.title;
    self.playTimesLabel.text = [NSString stringWithFormat:@"%.2f万", self.albumListModel.playtimes.floatValue / 10000];
    
    self.durationTimeLabel.text = [NSString stringWithFormat:@"%02d:%02d", self.albumListModel.duration.intValue / 60, self.albumListModel.duration.intValue % 60];
    
//时间戳赋值
    
    self.timeLabel.text = [TimeInteval shareGetUTCFormateDate:[NSString stringWithFormat:@"%lld", self.albumListModel.createdAt.longLongValue / 1000]];
    
}










- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
